package com.warski.wonderfires.page.setting;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.warski.wonderfires.R;
import com.warski.wonderfires.model.CommonListMenuItemInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by xuhaiping on 2020/8/29.
 * 菜单数据
 */
public class SettingMenuAdaopter extends BaseAdapter {
    private LayoutInflater inflater;
    private Context context;
    public List<CommonListMenuItemInfo> menuList = new ArrayList<CommonListMenuItemInfo>();

    public SettingMenuAdaopter(Context context) {
        this.context = context;
        inflater = LayoutInflater.from(this.context);

        /*menuList.add(new CommonListMenuItemInfo(this.context.getResources().getString(R.string.setting_menu_connect), R.mipmap.about_with_color));
        menuList.add(new CommonListMenuItemInfo(this.context.getResources().getString(R.string.setting_menu_device), R.mipmap.black_device));*/
        menuList.add(new CommonListMenuItemInfo(this.context.getResources().getString(R.string.setting_menu_language), R.mipmap.change_language));
        menuList.add(new CommonListMenuItemInfo(this.context.getResources().getString(R.string.setting_menu_operation), R.mipmap.help_with_color));
        menuList.add(new CommonListMenuItemInfo(this.context.getResources().getString(R.string.setting_menu_abountus), R.mipmap.about_with_color));
        menuList.add(new CommonListMenuItemInfo(this.context.getResources().getString(R.string.setting_menu_help), R.mipmap.msg_with_color));
    }

    @Override
    public int getCount() {
        return menuList.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.common_list_item, null);
        }
        CommonListMenuItemInfo menuItem = menuList.get(position);

        ImageView icon = convertView.findViewById(R.id.menuicon);
        icon.setBackgroundResource(menuItem.getIcon());
        TextView text = convertView.findViewById(R.id.menutext);
        if(menuItem.getName() != null){
            text.setText(menuItem.getName());
        }
        else{
            text.setText("");
        }
        return convertView;
    }

}
